<template>
  <view>
    <!-- 轮播图区域 -->
    <view class="swiper-box">
      <swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" :dots-styles="dotsStyles"
        circular="true">
        <swiper-item v-for="(item,index) in swiperList" v-bind:key="index">
          <view class="swiper-item" @click="gotoDetail(item.Class_id)">
            <image lazy-load v-bind:src="`//img.5211game.com/5211/shop/RPG/${item.Class_id}.jpg`" mode=""></image>
          </view>
        </swiper-item>
      </swiper>
    </view>

    <!-- 轮播图区域 -->
    <view class="search-box">
      <my-search></my-search>
    </view>
    <view class="main-cate">
      <view class="title">
        热门分类
      </view>
      <view class="dota" @click="gotoDotaView">
        <image lazy-load src="https://img.5211game.com/Base/xiaochengxu/static/dota.png"></image>
      </view>

      <view class="imba" @click="gotoImbaView">
        <image lazy-load src="https://img.5211game.com/Base/xiaochengxu/static/imba.png"></image>
      </view>

      <view class="juntuan" @click="gotoJuntuanView">
        <image lazy-load src="https://img.5211game.com/Base/xiaochengxu/static/juntuan.png"></image>
      </view>
      <view class="pt" @click="gotoPtView">
        <image lazy-load src="https://img.5211game.com/Base/xiaochengxu/static/pt.png"></image>
      </view>
    </view>
  </view>
</template>

<script>
  import badgeMix from '@/mixins/tabbar-badge.js'
  import {
    mapActions
  } from 'vuex'
  export default {
    data() {
      return {
        swiperList: [{
          'Class_id': 105
        }],
        limitLts: [],
        dotaLts: [],
        ptLts: [],
        category: 0,
        firstword: '',
        valName: '',
        pi: 1,
         
      };
    },
    mixins: [badgeMix],
    mounted() {
      if (uni.getStorageSync('token') && JSON.parse(uni.getStorageSync('userinfo')).userId > 0) {
        this._querywebcartgoods();
      }
      this.QueryRPGBySearchPager();
    },
    methods: {
      //获取限时抢购数据
      ...mapActions("m_cart", ["_querywebcartgoods"]),
      gotoPtView() {
        uni.navigateTo({
          url: '/subpkg/pt_view/pt_view'
        })
      },
      gotoDetail(cid) {
        uni.navigateTo({
          url: '/subpkg/rpg_view/rpg_view?cid=' + cid
        })
      },
      QueryRPGBySearchPager() {
        uni.$http.get(
          `/Query/QueryRPGBySearchPager?category=${this.category}&firstword=${this.firstword}&search=${escape(this.valName)}&pi=${this.pi}&ps=${this.ps}`
        ).then(({
          data: res
        }) => {
          if (res.code == 0) {
            this.swiperList = [];
            const arr = res.data.list.slice(0, 5);
            this.swiperList.push(...arr)
          }

        })
      },
      gotoDotaView() {
        uni.navigateTo({
          url: '/subpkg/dota_view/dota_view'
        })
      },
      gotoJuntuanView() {
        uni.navigateTo({
          url: '/subpkg/rpg_view/rpg_view?cid=' + 105
        })
      },
      gotoImbaView() {
        uni.navigateTo({
          url: '/subpkg/imba_view/imba_view'
        })
      },
      navClickHanlder(item) {
        uni.switchTab({
          url: `/pages/cate/cate`
        })
      }
    }
  }
</script>

<style lang="scss">
  body {
    background-color: #fff;
  }

  .swiper-box {
    width: 700rpx;
    border-radius: 30rpx;
    margin: 0 auto;

  }

  swiper {
    height: 360rpx;
    border-radius: 30rpx;

    .swiper-item,
    image {
      border-radius: 30rpx;
      width: 100%;
      height: 100%;
    }
  }

  .main-cate {
    width: 690rpx;
    overflow: hidden;
    zoom: 1;
    margin: 0 auto;

    .title {
      width: 670rpx;
      overflow: hidden;
      zoom: 1;
      color: #1A1A1A;
      font-weight: bold;
      font-size: 30rpx;
      position: relative;
      padding-left: 20rpx;
      margin-bottom: 15rpx;
    }

    .title::after {
      content: "";
      width: 4rpx;
      height: 19rpx;
      background-color: #F75403;
      position: absolute;
      left: 0px;
      top: 5px;
    }

    .dota {
      width: 690rpx;
      height: 240rpx;
      border-radius: 12px;
      margin-bottom: 20rpx;

      image {
        border-radius: 12px;
        width: 690rpx;
        height: 240rpx;
      }
    }

    .imba {
      width: 690rpx;
      height: 240rpx;
      border-radius: 12px;
      margin-bottom: 20rpx;

      image {
        border-radius: 12px;
        width: 690rpx;
        height: 240rpx;
      }
    }

    .juntuan {
      width: 690rpx;
      height: 240rpx;
      border-radius: 12px;
      margin-bottom: 20rpx;

      image {
        width: 690rpx;
        height: 240rpx;
        border-radius: 12px;
      }
    }

    .pt {
      width: 690rpx;
      height: 240rpx;
      border-radius: 12px;
      margin-bottom: 20rpx;

      image {
        border-radius: 12px;
        width: 690rpx;
        height: 240rpx;
      }
    }
  }
</style>
